package gaileenchess.tests;
import gaileenchess.*;

import java.util.Scanner;

public class HumanPlayerTest extends Test
{
    public HumanPlayerTest()
    {
        super("HumanPlayer");
    }
    
    // override the normal run function so we can first set up the scanner and suppress console printing
    public boolean run()
    {    
        Main.in = new Scanner(System.in);
        HumanPlayer.print = false;
        
        boolean pass = doTests();
        printSuccess(pass, "test", 1);
        return pass;
    }
    
    protected boolean doTests()
    {
        return test1();
    }
    
    private boolean test1()
    {
        boolean pass = true;
        HumanPlayer p = new HumanPlayer(Common.Side.WHITE, new Board());
        Command c;
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.NEW);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.NEW);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.NEW);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.FORFEIT);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.FORFEIT);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.NEW);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.FORFEIT);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.MOVE);
        pass &= (c.args[0].row == 1 && c.args[0].column == 0 && c.args[1].row == 6 && c.args[1].column == 7);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.MOVE);
        pass &= (c.args[0].row == 1 && c.args[0].column == 0 && c.args[1].row == 6 && c.args[1].column == 7);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.MOVE);
        pass &= (c.args[0].row == 1 && c.args[0].column == 0 && c.args[1].row == 6 && c.args[1].column == 7);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.FORFEIT);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.MOVE);
        pass &= (c.args[0].row == 1 && c.args[0].column == 0 && c.args[1].row == 6 && c.args[1].column == 7);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.DISPLAY);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.DISPLAY);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.NEW);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.DISPLAY);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.DISPLAY);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.INVALID);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.INVALID);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.INVALID);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.INVALID);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.INVALID);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.HELP);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.HELP);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.HELP);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.HELP);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.FORFEIT);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.VALID);
        pass &= (c.args[0].row == 1 && c.args[0].column == 0);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.INVALID);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.HINT);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.NEW);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.VALID);
        pass &= (c.args[0].row == 1 && c.args[0].column == 0);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.INVALID);
        c = p.getCommand();
        pass &= (c.type == Command.Cmd.HINT);
        
        //TODO: Cmd.SETUP
        
        printSuccess(pass, "test1");
        
        return pass;
    }
}
